<script>
export default {
  name: "EmptyState",
  props: {
    image: {
      type: String,
      default: "/empty.png",
    },
    text: {
      type: String,
      default: "暂无数据",
    },
    description: {
      type: String,
      default: "",
    },
    buttonText: {
      type: String,
      default: "",
    },
  },
  emits: ["action"],
  methods: {
    handleAction() {
      this.$emit("action");
    },
  },
};
</script>

<template>
  <div class="empty-state">
    <img :src="image" alt="空状态" class="empty-image" />
    <h3 class="empty-title">{{ text }}</h3>
    <p v-if="description" class="empty-description">{{ description }}</p>
    <el-button
      v-if="buttonText"
      type="primary"
      class="action-button"
      @click="handleAction"
    >
      {{ buttonText }}
    </el-button>
  </div>
</template>

<style scoped>
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}

.empty-image {
  width: 120px;
  height: 120px;
  margin-bottom: 1rem;
  opacity: 0.7;
}

.empty-title {
  font-size: 18px;
  color: #606266;
  margin-bottom: 0.5rem;
}

.empty-description {
  font-size: 14px;
  color: #909399;
  margin-bottom: 1rem;
}

.action-button {
  margin-top: 1rem;
}
</style>
